import { defineConfig } from 'vite'
import {viteObfuscateFile} from 'vite-plugin-obfuscator'
import uni from '@dcloudio/vite-plugin-uni'
export default defineConfig({
  plugins: [
    uni(),
    viteObfuscateFile({
      compact: true,
      controlFlowFlattening: false,
      controlFlowFlatteningThreshold: 0.75,
      deadCodeInjection: false,
      deadCodeInjectionThreshold: 0.4,
      debugProtection: false,
      debugProtectionInterval: 0,
      disableConsoleOutput: false,
      domainLock: [],
      domainLockRedirectUrl: 'about:blank',
      forceTransformStrings: [],
      identifierNamesCache: null,
      identifierNamesGenerator: 'hexadecimal',
      identifiersDictionary: [],
      identifiersPrefix: '',
      ignoreImports: false,
      inputFileName: '',
      log: false,
      numbersToExpressions: false,
      optionsPreset: 'default',
      renameGlobals: false,
      renameProperties: false,
      renamePropertiesMode: 'safe',
      reservedNames: [],
      reservedStrings: [],
      seed: 0,
      selfDefending: false,
      simplify: true,
      sourceMap: false,
      sourceMapBaseUrl: '',
      sourceMapFileName: '',
      sourceMapMode: 'separate',
      sourceMapSourcesMode: 'sources-content',
      splitStrings: false,
      splitStringsChunkLength: 10,
      stringArray: true,
      stringArrayCallsTransform: true,
      stringArrayCallsTransformThreshold: 0.5,
      stringArrayEncoding: [],
      stringArrayIndexesType: [
        'hexadecimal-number'
      ],
      stringArrayIndexShift: true,
      stringArrayRotate: true,
      stringArrayShuffle: true,
      stringArrayWrappersCount: 1,
      stringArrayWrappersChainedCalls: true,
      stringArrayWrappersParametersMaxCount: 2,
      stringArrayWrappersType: 'variable',
      stringArrayThreshold: 0.75,
      target: 'browser',
      transformObjectKeys: false,
      unicodeEscapeSequence: false
    })
                        
                      
    // compression({
    //   // 配置选项
    //   algorithm: 'gzip', // 可用的算法：'gzip', 'brotli', 'gzip-static', 'brotli-static'
    //   ext: '.gz.js', // 压缩文件的后缀
    //   threshold: 10240, // 压缩条件：大于此大小的文件会被压缩（以字节为单位）
    //   deleteOriginFile: true, // 压缩后是否删除原文件
    //   // 更多配置...
    // }),
  ],
  server: {
    proxy: {
      '/api': {
        target: 'https://kuigewuliu.henangaodu.com/', // 目标后端服务地址
        changeOrigin: true, // 是否改变源地址
        rewrite: (path) => path.replace(/^\/api/, ''), // 重写路径
      },
    },
  },
})

